/*
与后台交互模块 （依赖已封装的ajax函数）
 */
console.log('process.env.NODE_ENV', process.env.NODE_ENV);

import ajax from './ajax';
let BASE_URL;
if (process.env.NODE_ENV === 'development') {
  BASE_URL = '/api';
} else {
  BASE_URL = '/api';
}

// 拿到授权码后换取授权用户的信息
export const reqWechartLogin = data =>
  ajax(`${BASE_URL}/wechat/authorize/getauthorizeinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 注册验证
export const reqMemberCheck = data =>
  ajax(`${BASE_URL}/member/check`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 用户注册
export const reqMemberRegister = data =>
  ajax(`${BASE_URL}/member/register`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取短信验证码
export const reqSendCode = data =>
  ajax(`${BASE_URL}/sms/send`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 用户登录
export const reqMemberLogin = data =>
  ajax(`${BASE_URL}/member/login`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 修改登录密码
export const reqMemberChangePWD = data =>
  ajax(`${BASE_URL}/member/changepwd`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取用户登录信息
export const reqMemberInfo = data =>
  ajax(`${BASE_URL}/member/getauthorizedinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取用户信息
export const reqUserInfo = data =>
  ajax(`${BASE_URL}/member/getinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 修改用户信息
export const reqChangeUserInfo = data =>
  ajax(`${BASE_URL}/member/profile`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 重置登录密码
export const reqMemberResetPWD = data =>
  ajax(`${BASE_URL}/member/resetpwd`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 枚举所有专业科目信息列表
export const getAllProject = data =>
  ajax(`${BASE_URL}/course/getsubjects`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

//枚举指定专业下的套餐列表(首页列表)
export const getTaoChangList = data =>
  ajax(`${BASE_URL}/course/getpackages`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取专业科目下的目录列表
export const getTypeData = data =>
  ajax(`${BASE_URL}/course/getcatalogs`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 课程列表数据
export const getTaoChangData = data =>
  ajax(`${BASE_URL}/course/getpagelist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 免费课程列表
export const getKeChengData = data =>
  ajax(`${BASE_URL}/course/getfreelist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取套餐详情信息
export const getTaoChangeDetail = data =>
  ajax(`${BASE_URL}/course/getpackageinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });
// 获取课程详情信息
export const getKeChengDetail = data =>
  ajax(`${BASE_URL}/course/getcourseinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

//创建订单
export const reqOrderCreate = data =>
  ajax(`${BASE_URL}/order/create`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取订单列表
export const getOrderList = data =>
  ajax(`${BASE_URL}/order/getlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 删除订单列表
export const delOrder = data =>
  ajax(`${BASE_URL}/order/delete`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });
// 获取订单详情
export const reqOrderDetail = data =>
  ajax(`${BASE_URL}/order/getinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 微信支付下单
export const reqwxpay = data =>
  ajax(`${BASE_URL}/wxpay/wxpay/unifiedorder`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

/**** 历年真题 ****/

// 历年真题列表
export const calendar_qus_list = data =>
  ajax(`${BASE_URL}/calendar/getlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取试题封面详情
export const calendar_info = data =>
  ajax(`${BASE_URL}/calendar/getinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 题目详情
export const calendar_qus = data =>
  ajax(`${BASE_URL}/calendar/tostart`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 保存单个题目的答案
export const calendar_save_one = data =>
  ajax(`${BASE_URL}/calendar/toanswer`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 提交试卷的答案
export const calendar_submit = data =>
  ajax(`${BASE_URL}/calendar/tosubmit`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

/**** 模拟考试计划 ****/

// 模拟考试计划列表
export const plan_qus_list = data =>
  ajax(`${BASE_URL}/plan/getlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取试题封面详情
export const plan_info = data =>
  ajax(`${BASE_URL}/plan/getinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 题目详情
export const plan_qus = data =>
  ajax(`${BASE_URL}/plan/tostart`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 保存单个题目的答案
export const plan_save_one = data =>
  ajax(`${BASE_URL}/plan/toanswer`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 提交试卷的答案
export const plan_submit = data =>
  ajax(`${BASE_URL}/plan/tosubmit`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

/**** 章节练习(没有封面) ****/

// 章节列表
export const chapter_qus_list = data =>
  ajax(`${BASE_URL}/chapter/getlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 题目详情
export const chapter_qus = data =>
  ajax(`${BASE_URL}/chapter/tostart`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 保存单个题目的答案
export const chapter_save_one = data =>
  ajax(`${BASE_URL}/chapter/toanswer`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 提交试卷的答案
export const chapter_submit = data =>
  ajax(`${BASE_URL}/chapter/tosubmit`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

/**** 每日一练(没有封面) ****/

// 章节列表
export const dayly_qus_list = data =>
  ajax(`${BASE_URL}/dayly/getlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 题目详情
export const dayly_qus = data =>
  ajax(`${BASE_URL}/dayly/tostart`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 保存单个题目的答案
export const dayly_save_one = data =>
  ajax(`${BASE_URL}/dayly/toanswer`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 提交试卷的答案
export const dayly_submit = data =>
  ajax(`${BASE_URL}/dayly/tosubmit`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

/**** 随机刷新(没有封面和列表) ****/

// 题目详情
export const exercise_qus = data =>
  ajax(`${BASE_URL}/exercise/tostart`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 保存单个题目的答案
export const exercise_save_one = data =>
  ajax(`${BASE_URL}/exercise/toanswer`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 提交试卷的答案
export const exercise_submit = data =>
  ajax(`${BASE_URL}/exercise/tosubmit`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 收藏课程
export const reqCollection = data =>
  ajax(`${BASE_URL}/member/tocollection`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });
// 上传图片
export const reqUploadAvatar = data =>
  ajax(`${BASE_URL}/member/setavatar`, data, 'POST', {
    'Content-Type': 'multipart/form-data',
  });

// 获取新闻列表
export const reqNewsList = data =>
  ajax(`${BASE_URL}/archive/getlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取新闻详情
export const reqNewsDetails = data =>
  ajax(`${BASE_URL}/archive/getinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取指定分类/属性的文章列表
export const reqNewsListTop = data =>
  ajax(`${BASE_URL}/archive/getrows`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// T获取用户做题统计信息
export const reqGetExamCount = data =>
  ajax(`${BASE_URL}/exam/getcount`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取用户做题统计信息
export const reqLearnHis = data =>
  ajax(`${BASE_URL}/member/getcourserecord`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取用户购买成功的套餐列表
export const reqBuyed = data =>
  ajax(`${BASE_URL}/member/getpackages`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取做题记录
export const reqDoRecord = data =>
  ajax(`${BASE_URL}/member/getexamdata`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取当前用户错题统计
export const reqFaileCount = data =>
  ajax(`${BASE_URL}/exam/getfailedcount`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取指定类型的错题列表
export const reqFaileList = data =>
  ajax(`${BASE_URL}/exam/getfailedlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取当前用户收藏统计
export const reqCollectCount = data =>
  ajax(`${BASE_URL}/exam/getcollectioncount`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取指定类型的收藏列表
export const reqCollectList = data =>
  ajax(`${BASE_URL}/exam/getcollectionlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 更新学习记录
export const reqSetRecord = data =>
  ajax(`${BASE_URL}/course/setrecord`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 获取幻灯片数据
export const reqFlash = data =>
  ajax(`${BASE_URL}/index/getflash`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 问答列表
export const reqAskList = data =>
  ajax(`${BASE_URL}/ask/getlist`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 问答详情
export const reqAskDetail = data =>
  ajax(`${BASE_URL}/ask/getinfo`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

// 查看解析
export const calendar_view = data =>
  ajax(`${BASE_URL}/calendar/toview`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

export const plan_view = data =>
  ajax(`${BASE_URL}/plan/toview`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

export const chapter_view = data =>
  ajax(`${BASE_URL}/chapter/toview`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

export const dayly_view = data =>
  ajax(`${BASE_URL}/dayly/toview`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });

export const exercise_view = data =>
  ajax(`${BASE_URL}/calendar/toview`, data, 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  });
